package com.incito.crawl.common.httpclient;

import com.incito.crawl.common.utils.proxy.ProxyInfo;
import org.apache.http.client.protocol.HttpClientContext;

/**
 * Created by wuyu on 2014/7/11.
 */
public class CrawlHttpClientContext extends HttpClientContext {
    private Boolean useProxy = true;
    private String proxyRuleName = null;
    private ProxyInfo proxyInfo = null;
    private Boolean useProxyInfo = false;


    public Boolean getUseProxy() {
        return useProxy;
    }

    public void setUseProxy(Boolean useProxy) {
        this.useProxy = useProxy;
    }

    public String getProxyRuleName() {
        return proxyRuleName;
    }

    public void setProxyRuleName(String proxyRuleName) {
        this.proxyRuleName = proxyRuleName;
    }

    /**
     * 设置单独的Proxy
     * @return
     */
    public ProxyInfo getProxyInfo() {
        return proxyInfo;
    }

    public void setProxyInfo(ProxyInfo proxyInfo) {
        this.proxyInfo = proxyInfo;
    }

    /**
     * 是否使用CrawlHttpClientContext自带的ProxyInfo
     * ProxyRoutePlanner将基于该标识位判断是否使用context自带的proxyInfo
     * （条件：useProxy=true and useProxyInfo=true and proxyInfo != null）
     * @return
     */
    public Boolean getUseProxyInfo() {
        return useProxyInfo;
    }

    public void setUseProxyInfo(Boolean useProxyInfo) {
        this.useProxyInfo = useProxyInfo;
    }
}
